//package com.abl.common.controller;
//
//import com.abl.core.common.util.IdKit;
//import com.abl.core.domain.po.ADefault;
//import com.abl.core.domain.project.SRS;
//import com.abl.core.mybatis.mapper.ADefaultMapper;
//import com.mybatisflex.core.query.QueryWrapper;
//import com.mybatisflex.core.row.Db;
//import com.mybatisflex.core.row.Row;
//import jakarta.annotation.Resource;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@RestController
//@RequestMapping("/common/demo")
//public class DefaultController {
//
//    @Resource
//    private ADefaultMapper defaultMapper;
//
//    @PostMapping("/delete")
//    public SRS<Object> delete() {
//        QueryWrapper wrapper = new QueryWrapper();
//        wrapper.select("*").from("lk_user_role").where("user_id =?", "1");
//        List<Object> list = DB.listObj(wrapper);
//        System.out.println();
//
//        //已通过：使用原生 SQL 插入数据
//        return SRS.bySuccess();
//    }
//
//    @PostMapping("/add")
//    public SRS<Object> add() {
//        //使用原生 SQL 插入数据；不走自动填充
////        String sql = "insert into a_default(id) value (?)";
////        Db.insertBySql(sql, System.currentTimeMillis() + "");
//
//
//        //使用 Row 插入数据；不走自动填充
////        Row account = new Row();
////        account.set("id", System.currentTimeMillis() + "");
////        Db.insert("a_default", account);
//
//        //；走自动填充
//        ADefault aDefault3 = new ADefault();
//        DB.insert(aDefault3);
//
//        //；走自动填充
//        ADefault aDefault4 = new ADefault();
//        DB.insert(aDefault4, "ds2");
//
//
//        //批量插入；走自动填充
//        ArrayList<ADefault> objects = new ArrayList<>();
//        ADefault aDefault33 = new ADefault();
//        aDefault33.setId(IdKit.getId());
//
//        ADefault aDefault44 = new ADefault();
//        aDefault44.setId(IdKit.getId());
//
//        objects.add(aDefault33);
//        objects.add(aDefault44);
//        DB.insert(objects);
//        DB.insert(objects, "ds2");
//
//        List<Row> rows = Db.selectListByQuery("a_default", new QueryWrapper());
//
//        return SRS.bySuccess(rows);
//
////
////        //根据主键查询数据
////        Row row = Db.selectOneById("tb_account", "id", 1);
////
////        //Row 可以直接转换为 Entity 实体类，且性能极高
////        Account account = row.toEntity(Account.class);
////
////
////        //查询所有大于 18 岁的用户
////        String listsql = "select * from tb_account where age > ?"
////        List<Row> rows = Db.selectListBySql(listsql, 18);
////
////
////        //分页查询：每页 10 条数据，查询第 3 页的年龄大于 18 的用户
////        QueryWrapper query = QueryWrapper.create()
////                .where(ACCOUNT.AGE.ge(18));
////        Page<Row> rowPage = Db.paginate("tb_account", 3, 10, query);
//
//    }
//
////    @Resource
////    private SysDemoService service;
////
////    @Resource
////    private Dao dao;
////
////    /**
////     * 两种形式的添加操作
////     */
////    @PostMapping("/add")
////    public SRS<Object> add(@RequestBody Param<Object> param) {
////        //通用-插入
////        //
////        //插入通用对象
////        Dnt insertDnt = Dnt.create();
////        insertDnt.set("id", IdKit.getId());
////        long aDefault = dao.insert("a_default", insertDnt);
////
////        //批量插入通用-实体类
////        //要求所有实体类，key-value 一直
////        ArrayList<Dnt> objects1 = new ArrayList<>();
////        Dnt insert2 = Dnt.create();
////        insert2.set("id", IdKit.getId());
////        objects1.add(insert2);
////        long l = dao.insertBatch("a_default", objects1);
////
////        //
////        //
////
////        //库表实体类-插入
////        //
////        //插入库表对应实体类
////        ADefaultPO aDefaultPO = new ADefaultPO();
////        aDefaultPO.setId(IdKit.getId());
////        long insert1 = dao.insert(aDefaultPO);
////
////        //批量插入库表-实体类
////        ArrayList<ADefaultPO> tablePO = new ArrayList<>();
////        ADefaultPO aDefaultPO2 = new ADefaultPO();
////        aDefaultPO2.setId(IdKit.getId());
////        tablePO.add(aDefaultPO2);
////        long l1 = dao.insertBatch(tablePO);
////
////        return SRS.bySuccess();
////    }
////
////    /**
////     * 两种形式的删除操作
////     */
////    @PostMapping("/delete")
////    public SRS<Object> delete(@RequestBody Param<Object> param) {
////        //通用删除
////        //
////        Wrapper<ADefaultPO> wrapper = new Wrapper<>();
////        wrapper.eq("id", 1);
////        long aDefault = dao.delete("a_default", wrapper);
////
////        //通用删除
////        long l = dao.deleteById("a_default", "1136298559264522240");
////
////        //通用删除
////        long l1 = dao.deleteByIds("a_default", Arrays.asList("1136298559377768448"));
////
////        //库表实体类删除
////        Wrapper<ADefaultPO> defaultPOWrapper = new Wrapper<>(ADefaultPO.class);
////        defaultPOWrapper.eq("id", "1136298559436488704");
////        long delete = dao.delete(defaultPOWrapper);
////
////        return SRS.bySuccess();
////    }
////
////    @PostMapping("/update")
////    public SRS<Object> update(Param<Object> param) {
////        //通用修改
////        Wrapper<Object> updateWP_1 = new Wrapper<>();
////        updateWP_1.eq("id", "1");
////        updateWP_1.set("name", "001");
////        //通用修改
////        dao.update("a_default", updateWP_1);
////
////        //通用修改
////        Dnt dnt_2 = new Dnt();
////        dnt_2.set("name", "001");
////        Wrapper<Object> updateWP_2 = new Wrapper<>();
////        updateWP_2.eq("id", "1");
////        //通用修改
////        dao.update("a_default", dnt_2, updateWP_2);
////
////        //通用修改
////        Dnt dnt_3 = new Dnt();
////        dnt_3.set("id", "1");
////        dnt_3.set("name", "001");
////        //通用修改
////        dao.updateById("a_default", dnt_3);
////        //通用修改
////        dao.updateByKey("a_default", dnt_3, "id");
////
////
////        //数据库实体类修改
////        Wrapper<ADefaultPO> wrapper = new Wrapper<>();
////
////
////        System.out.println(param);
////        return SRS.bySuccess();
////    }
////
////    @PostMapping("/list")
////    public SRS<Object> list(Param<Object> param) {
////        System.out.println(param);
////        return SRS.bySuccess();
////    }
//
////
////
////    @PostMapping("/insert")
////    public SRS<Object> insert(SysUser param) {
////        RLock lock = redisson.getLock(CacheKey.LOCK_USER_LOGIN + "123");
////        try {
////            lock.lock();
////            boolean add = sysUserService.insert(param);
////        } finally {
////            lock.unlock();
////        }
////        return SRS.bySuccess();
////    }
////
////    @PostMapping("/update")
////    public SRS<Object> update(SysUser param) {
////        RLock lock = redisson.getLock(CacheKey.LOCK_USER_LOGIN + "123");
////        try {
////            lock.lock();
//////            ADefault aDefault1 = new ADefault();
//////            aDefault1.setId("1137416670759878656");
//////            aDefault1.setSort(1000);
//////
//////            ADefault aDefault2 = new ADefault();
//////            aDefault2.setId("1137416861592322048");
//////            List<ADefault> list = Arrays.asList(aDefault1, aDefault2);
////            //TODO 这种不行，会默认存储控制
//////            int i = Db.updateEntitiesBatch(list);
////
////
////            List<ADefault> aDefaults1 = DB.listById(ADefault.class, "*", Arrays.asList("1137416670759878656", "1137416861592322048"), ADefault.class);
////            List<ADefault> aDefaults2 = DB.listByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"), ADefault.class);
////
////            List<ADefault> aDefaults3 = DB.listById(ADefault.class, "*", Arrays.asList("1137416670759878656", "1137416861592322048"), ADefault.class);
////            List<ADefault> aDefaults4 = DB.listByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"), ADefault.class);
////
////            List<JSONObject> objects = DB.listById(ADefault.class, "*", Arrays.asList("1137416670759878656", "1137416861592322048"));
////            List<JSONObject> objects1 = DB.listByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////
////            List<JSONObject> objects2 = DB.listById(ADefault.class, "*", Arrays.asList("1137416670759878656", "1137416861592322048"));
////            List<JSONObject> objects3 = DB.listByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////
////
////            ADefault aDefault = DB.selectOneById(ADefault.class, "*", "1137416670759878656", ADefault.class);
////            ADefault aDefault3 = DB.selectOneByKey(ADefault.class, "id", "id", "1137416670759878656", ADefault.class);
////
////            ADefault aDefault4 = DB.selectOneById(ADefault.class, "*", "1137416670759878656", ADefault.class);
////            ADefault aDefault5 = DB.selectOneByKey(ADefault.class, "id", "id", "1137416670759878656", ADefault.class);
////
////            ADefault aDefault6 = DB.selectOneById(ADefault.class, "*", "1137416670759878656", ADefault.class);
////            ADefault aDefault7 = DB.selectOneByKey(ADefault.class, "id", "id", "1137416670759878656", ADefault.class);
////
////
////            ADefault aDefault1 = DB.selectOneById(ADefault.class, "*", "1137416670759878656");
////            ADefault aDefault2 = DB.selectOneByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////            ADefault aDefault8 = DB.selectOneById(ADefault.class, "*", "1137416670759878656");
////            ADefault aDefault10 = DB.selectOneByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////            ADefault aDefault11 = DB.selectOneById(ADefault.class, "*", "1137416670759878656");
////            ADefault aDefault12 = DB.selectOneByKey(ADefault.class, "id", "id", "1137416670759878656");
//////
//////
//////
//////
////
////
////            List<Object> aDefaults11 = DB.listObjById(ADefault.class, "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////            List<Object> aDefaults22 = DB.listObjByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////
////            List<Object> aDefaults33 = DB.listObjById(ADefault.class, "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////            List<Object> aDefaults44 = DB.listObjByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////
////            List<Object> objects5 = DB.listObjById(ADefault.class, "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////            List<Object> objects16 = DB.listObjByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////
////            List<Object> objects27 = DB.listObjById(ADefault.class, "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////            List<Object> objects38 = DB.listObjByKey(ADefault.class, "id", "id", Arrays.asList("1137416670759878656", "1137416861592322048"));
////
////
////            Object aDefault9 = DB.selectObjById(ADefault.class, "id", "1137416670759878656");
////            Object aDefault31 = DB.selectObjByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////            Object aDefault42 = DB.selectObjById(ADefault.class, "id", "1137416670759878656");
////            Object aDefault53 = DB.selectObjByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////            Object aDefault64 = DB.selectObjById(ADefault.class, "id", "1137416670759878656");
////            Object aDefault75 = DB.selectObjByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////
////            Object aDefaul16 = DB.selectObjById(ADefault.class, "id", "1137416670759878656");
////            Object aDefaul27 = DB.selectObjByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////            Object aDefaul38 = DB.selectObjById(ADefault.class, "id", "1137416670759878656");
////            Object aDefaul49 = DB.selectObjByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////            Object aDefaul51 = DB.selectObjById(ADefault.class, "id", "1137416670759878656");
////            Object aDefaul62 = DB.selectObjByKey(ADefault.class, "id", "id", "1137416670759878656");
////
////
////            System.out.println();
////
////        } finally {
////            lock.unlock();
////        }
////        return SRS.bySuccess();
////    }
////
////    @PostMapping("/delete")
////    public SRS<Object> delete(String param) {
////        RLock lock = redisson.getLock(CacheKey.LOCK_USER_LOGIN + "123");
////        try {
////            lock.lock();
////            sysUserService.delete(param);
////        } finally {
////            lock.unlock();
////        }
////        return SRS.bySuccess();
////    }
////
////    @PostMapping("/page")
////    public SRS<Object> page(Param param) {
////        QueryWrapper queryWrapper = new QueryWrapper();
////        queryWrapper
////                .select("a_default.*")
////                .from(ADefault.class)
////                .leftJoin("sys_user")
////                .on("a_default.id != sys_user.id ")
////                .where("a_default.id!=0 or sys_user.id!=0");
////        String sql = queryWrapper.toSQL();
//////        Page<JSONObject> page = DB.page(1, 2, queryWrapper);
//////        List<JSONObject> records = page.getRecords();
//////
//////        Page<ADefault> page1 = DB.page(1, 2, queryWrapper, ADefault.class);
//////        List<ADefault> records1 = page1.getRecords();
//////
//////        Page<JSONObject> page2 = DB.page(1, 2, queryWrapper.toSQL());
//////        List<JSONObject> records2 = page2.getRecords();
//////
//////        Page<ADefault> page3 = DB.page(1, 2, queryWrapper.toSQL(), ADefault.class);
//////        List<ADefault> records3 = page3.getRecords();
////
//////        Page<JSONObject> page4 = DB.page(1, 2, queryWrapper, "ds2");
//////        List<JSONObject> records4 = page4.getRecords();
////
//////        Page<ADefault> ds2 = DB.page(1, 2, queryWrapper, ADefault.class, "ds2");
//////        List<ADefault> records5 = ds2.getRecords();
////
//////        Page<JSONObject> page5 = DB.page(1, 2, queryWrapper.toSQL(), "ds2");
//////        List<JSONObject> records6 = page5.getRecords();
////
//////        Page<ADefault> ds21 = DB.page(1, 2, queryWrapper.toSQL(), ADefault.class, "ds2");
//////        List<ADefault> records7 = ds21.getRecords();
////
////        System.out.println();
////        //
////        //
////        //
////        queryWrapper = new QueryWrapper();
////        queryWrapper
////                .select("count(1)")
////                .from(ADefault.class)
////                .where("id!=0");
////        long count1 = DB.count("select count(*) from a_default where id!=0");
////        long count2 = DB.count("select count(*) from a_default where id!=0", "ds2");
////        long count3 = DB.count(queryWrapper);
////        long count4 = DB.count(queryWrapper, "ds2");
////
////        //
////        //
////        //
////        queryWrapper = new QueryWrapper();
////        queryWrapper
////                .select("*")
////                .from(ADefault.class)
////                .where("id!=0");
////
////        List<JSONObject> list1 = DB.list(queryWrapper);
////        List<JSONObject> list2 = DB.list(queryWrapper, "ds2");
////        List<ADefault> list3 = DB.list(queryWrapper, ADefault.class);
////        List<ADefault> list4 = DB.list(queryWrapper, ADefault.class, "ds2");
////
////
////        JSONObject entity1 = DB.selectOne(queryWrapper);
////        JSONObject entity2 = DB.selectOne(queryWrapper, "ds2");
////        ADefault entity3 = DB.selectOne(queryWrapper, ADefault.class);
////        ADefault entity4 = DB.selectOne(queryWrapper, ADefault.class, "ds2");
////
////
////        System.out.println("list1==> " + JSONObject.toJSONString(list1));
////        System.out.println();
////
////        System.out.println("list2==> " + JSONObject.toJSONString(list2));
////        System.out.println();
////
////        System.out.println("list3==> " + JSONObject.toJSONString(list3));
////        System.out.println();
////
////        System.out.println("list4==> " + JSONObject.toJSONString(list4));
////        System.out.println();
////
////
////        System.out.println("entity1==> " + JSONObject.toJSONString(entity1));
////        System.out.println();
////
////        System.out.println("entity2==> " + JSONObject.toJSONString(entity2));
////        System.out.println();
////
////        System.out.println("entity3==> " + JSONObject.toJSONString(entity3));
////        System.out.println();
////
////        System.out.println("entity4==> " + JSONObject.toJSONString(entity4));
////        System.out.println();
////
////
////        System.out.println("count1==>" + count1);
////        System.out.println();
////
////
////        System.out.println("count2==>" + count2);
////        System.out.println();
////
////
//////        List<Row> rows = Db.selectListBySql("select * from a_default where id!=0");
//////        List<ADefault> entityList = RowUtil.toEntityList(rows, ADefault.class);
//////        System.out.println(JSONObject.toJSONString(entityList));
//////        List list1 = sysUserService.page(param);
////        return SRS.bySuccess();
////    }
////
////    @PostMapping("/userInfo")
////    public SRS<Object> systemUserInfo() {
////        SysUser sysUser = sysUserService.systemUserInfo();
////        return SRS.bySuccess(sysUser);
////    }
////
////    @PostMapping("/userMenu")
////    public SRS<List<SysMenu>> systemUserMenu() {
////        List<SysMenu> menus = sysUserService.systemUserMenu();
////        return SRS.bySuccess(menus);
////    }
////
////
////    @PostMapping("/login")
////    public SRS<Object> systemUserLogin(String loginFormStr) throws Exception {
////        JSONObject param = sysUserService.checkLoginExpire(loginFormStr);
////
////        captchaService.valid(param.getString("id"), param.getString("code"));
////
////        TokenVO tokenVO = sysUserService.userLogin(param.getString("account"), param.getString("password"), param.getString("type"));
////
////        return SRS.bySuccess(tokenVO);
////    }
////
////    @PostMapping("/register")
////    public SRS<Object> systemUserRegister(String loginFormStr) throws Exception {
////        JSONObject param = sysUserService.checkLoginExpire(loginFormStr);
////
////        captchaService.valid(param.getString("id"), param.getString("code"));
////
////        boolean isSuccess = sysUserService.userRegister(param.getString("account"), param.getString("password"), param.getString("type"));
////
////        return SRS.bySuccess(isSuccess);
////    }
////
////    /**
////     * 生成验证码
////     */
////    @PostMapping("/captchaImage")
////    public SRS<Object> captchaImage() {
////        return SRS.bySuccess(captchaService.createMathCaptchaImage());
////    }
//
//
//}
